﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
    <xsl:include href="_Common.xsl"/>

    <xsl:template match="/">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <xsl:call-template name="Header">
                <xsl:with-param name="Title" select="/directoryListing/@title"/>
            </xsl:call-template>
            <body>
                <div class="header">
                    <h1>
                        <xsl:value-of select="$ConfiguredTitle"/>
                    </h1>
                    <xsl:if test="/directoryListing/@isRoot!='True'">
                        <h2>
                            <xsl:value-of select="/directoryListing/@title"/>
                        </h2>
                    </xsl:if>
                </div>
                <!-- Display directory listing -->
                <div class="directories">
                    <ul>
                        <xsl:if test="/directoryListing/@isRoot!='True'">
                            <!-- Not root - display parent link -->
                            <li>
                                <a href="../">[parent folder]</a>
                            </li>
                        </xsl:if>
                        <!-- Vypsat podsložky -->
                        <xsl:for-each select="/directoryListing/folder">
                            <xsl:sort select="@title"/>
                            <li>
                                <a href="{@name}/">
                                    <xsl:value-of select="@title"/>
                                </a>
                            </li>
                        </xsl:for-each>
                    </ul>
                </div>
                <!-- List files -->
                <xsl:if test="/directoryListing/file">
                    <div class="files">
                        <xsl:for-each select="/directoryListing/file">
                            <xsl:sort select="@title"/>
                            <a href="{@name}.html">
                                <img src="{@name}.tn" alt="{concat(@title, ' (', format-number(@size div 1024, '### ### ##0'), ' kB)')}" width="150" height="150" />
                            </a>
                        </xsl:for-each>
                    </div>
                </xsl:if>
                <!-- Display footer -->
                <xsl:call-template name="Footer" />
            </body>
        </html>
    </xsl:template>

</xsl:stylesheet>